
/*
 * This class read a file in a directory and add
 * all words in the file to a WordList object. 
 */
package cth.tda367.beavers.glossaryGame.IO;

import java.util.*;
import java.io.*;

import cth.tda367.beavers.glossaryGame.model.Word;
import cth.tda367.beavers.glossaryGame.model.WordList;


public class TextReader {
	
	public static TextReader INSTANCE;
	String fileName = "c:/";
	
	WordList list = new WordList();
	
	public static TextReader getInstance() {
			INSTANCE = new TextReader();
		return INSTANCE;
		
	}
	
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	
	public String getFileName () {
		return fileName;
	}
	
	public void readFile() {
		
		try {

			Scanner sc = new Scanner(new BufferedReader(new FileReader("c:/GlossaryGame/"+fileName)));



			while (sc.hasNext()) {
				
				list.addNewWord(new Word(sc.next(), sc.next()));
				
			}

			
			list.getWord(0);
		} catch (IOException e) {
			System.err.println(e.getMessage());
		}
		
		
	}
	
	
	public TextReader() {
		
		
		
			
	}

	public WordList getWordList() {
		return (WordList)list;
	}
}
